home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
dskut
/
toadshr1.zip
/
TOADSHR1.PAS
< prev
Wrap
Pascal/Delphi Source File
|
1989-06-14
|
36KB
|
1,012 lines
PROGRAM ToadShar;
{ Toad Hall Shar v1.1 for Turbo Pascal v5.0
Other shars available for MS-DOS had no wildcard capability,
and I got BLOODY tired of typing in all those filenames!
This one's got wildcard capability (both for shar creation and extraction).
I've arbitrarily decided to force the world to accept the MS-DOS shar
file type of ".SHR" for a shar file type (when wildcard extracting)
(since we can't use the Unix ".shar" standard).
You don't like it? Recode it!
No, I don't know how to change it for Turbo Pascal v4.0.
Usage:
shar [-u] [file1]..[filen]
Where file1..filen can be up to 20 MS-DOS path\filenames
(wildcarded if you wish). (The 20 was arbitrary .. see MAXARGS.)
-u Unshar (extract) members from shar file(s).
Yes, the -u (any case) MUST be the first command line parameter!
shar filenames can be full DOS paths, with a default file
type of ".SHR" (added if required).
During shar creation:
The .SHR files produced will be simplistic (e.g., none of the fancy
Unix switches are available). However, they should be compatible
with Unix shars (provided you work around the line ending problem,
of course).
Shar-formatted output is to StdOut (e.g., via redirection at the
DOS command line). No check is made for an output file's existence
(naturally). Output is standard DOS text file (e.g., CR/LF line
endings).
No tests are made to filter out control characters, etc., and target
member files are treated as text files. I would NOT suggest using
this shar on anything but pure Ascii text files!
Any error msgs will go to StdOut (yep, the file you're creating!).
Sorry 'bout that .. don't wanna mess with a StdErr output routine
at this time. Maybe later.
During extraction:
You can wildcard the extracting. (E.g., if you have FOO1.SHR and
FOO2.SHR, just enter "TOADSHAR FOO*" and both files will be unshared.)
Existing files will NOT be overwritten! You'll get a warning message,
and shar will continue to work its way through the remaining shar file
members (if any).
No tests are made (to date) to replicate sed or sh errorchecking
(e.g., the simplistic character count).
Some sed/sh "echo" commands are echoed to StdOut during extraction.
I've tested TOADSHAR on Unix and MS-DOS .shar files created with various
switch settings .. seems to work ok.
This sucker isn't ALL it could be yet .. could use more file read/write
error trapping, more sophisticated sh-like testing (char counts,
file overwriting, etc.) .. but it'll do for now.
Credits:
Fancy dynamic arrays of FindFirst and FindNext SearchRecs,
thanks to a hack of:
"Linked list modules from LINKLIST.PAS"
Copyright (c) 1985 by Alan D. Hull
Boyer-Moore string searching (credits, source in POSBM.ASM)
Released to the public domain.
Constraints: Do NOT distribute without source and documentation.
Do NOT remove credits.
David P Kirschbaum
Toad Hall
kirsch@braggvax.ARPA
(or maybe kirsch%braggvax.ARPA@cacfs.army.mil)
(919) 868-3471 voice/data
v1.0 Original release
v1.1 Added:
new posBM and posCH POS() replacements.
StdErr message output.
}
{$B-} {shortcut Boolean logic}
{$D-} {No debug info}
{$F-} {No far calls}
{$L-} {No local symbol info}
{$R-} {No range checking}
{$S-} {No stack checking .. taking a chance on this one
for systems with VERY limited memory ..
You don't like it? Recompile it.}
{$V-} {Relaxed VAR string parm testing}
{ DEFINE Debug} {enable for some debug displays, file overwriting, etc.}
Uses Dos; {for the Find First/Find Next stuff}
TYPE
Str20 = STRING[20];
Str80 = STRING[80];
CONST
QUOTE = #39; {single-quotation mark/apostrophe char}
MAXARGS = 20; {change as you like}
VERSION = 'v1.1';
CRLF : ARRAY[1..2] OF CHAR = #$0D#$0A; {v1.1}
VAR
argv, argc : Byte;
Args : ARRAY[1..MAXARGS] {array of cmdline parms}
OF PathStr; {STRING[79]}
InFile : TEXT;
{
SearchRec, DirStr, NameStr, ExtStr are declared in the Dos unit.
As a reminder:
TYPE SearchRec = RECORD
fill : ARRAY[1..21] OF Byte;
attr : Byte;
time : longint;
size : longint;
Name : STRING[12];
END;
}
SrchRec : SearchRec;
Dir : DirStr; {STRING[79]}
Name: NameStr; {STRING[8]}
Ext : ExtStr; {STRING[4]}
CONST
{The shar file header (picked from a handy Unix speciman).
This array of array of chars is a kludge, I know .. but it was the
simplest/fastest way to collect one big hunk of characters for output.
Now if I wanted to add my block read/writes .. but then we wouldn't
have a nice neat TEXT file, would we?
}
(*
Hdr1 : ARRAY[1..26] OF CHAR = '# This is a shell archive.';
Hdr2 : ARRAY[1..53] OF CHAR =
'# Remove everything above and including the cut line.';
Hdr3 : ARRAY[1..43] OF CHAR =
'# Then run the rest of the file through sh.';
Hdr4 : ARRAY[1..57] OF CHAR =
'#----cut here-----cut here-----cut here-----cut here----#';
Hdr5 : ARRAY[1..9] OF CHAR = '#!/bin/sh';
Hdr6 : ARRAY[1..25] OF CHAR = '# shar: Shell Archiver';
Hdr7 : ARRAY[1..48] OF CHAR =
'# Run the following text with /bin/sh to create:';
*)
NR_HDRLINES = 4;
Hdr : ARRAY[1..NR_HDRLINES] OF Str80 =
(
'# This is a shell archive.'#$0D#$0A'# Remove everything above and including the cut ',
'line.'#$0D#$0A'# Then run the rest of the file through sh.'#$0D#$0A'#----cut here-----cut here',
'-----cut here-----cut here----#'#$0D#$0A'#!/bin/sh'#$0D#$0A'# shar: Shell Archiver',
#$0D#$0A'# Run the following text with /bin/sh to create:'#$0D#$0A
);
{Load our posBM and posCH modules}
{$F+}
{$L POSBM}
FUNCTION posBM(Pat,Str : STRING) : BYTE; EXTERNAL;
{$L POSCH}
FUNCTION posCH(Ch : CHAR; S : STRING) : BYTE; EXTERNAL;
{And our StdErr procedure}
{$L STDERR}
PROCEDURE Write_StdErr(S : STRING); EXTERNAL;
{$F-}
{
(Linked list modules from LINKLIST.PAS)
Copyright (c) 1985 by Alan D. Hull
TURBO LinkList modules and descriptions are hereby donated to
the public domain. They may be included in any other free
software without royalties to the author. TURBO LinkList
procedures, descriptions and/or declarations may not be
included in whole or in part in any program, function, or
package sold for commercial gain, without the express
permission of the author.
Thanks, Alan .. gee, 1985 .. sigh ..
}
TYPE
{ We don't really NEED the entire SearchRec saved (from a FindFirst
or FindNext) .. but I'm keeping it handy for now.
Actually, all we need is the Dir and SearchRec.Name (for opening
input files later).
}
SrchRecPtr = ^node;
node = RECORD { this is the linked list node }
flink,
blink : SrchRecPtr;
SrchRec : SearchRec; { map in a data record }
Dir : DirStr; {remember the directory also}
END;
VAR
head, tail, curr, Temp : SrchRecPtr;
PROCEDURE Allocate_Node( VAR node_ptr: SrchRecPtr);
{ Allocate a node of a doubly-linked list }
BEGIN
NEW (node_ptr); { get a new block of memory }
node_ptr^.flink := NIL; { make sure it doesn't point to }
node_ptr^.blink := NIL; { any other nodes yet. }
END;
PROCEDURE Add_After_Node (VAR head, tail, current, newp: SrchRecPtr);
{ Add the node to the linked list
head - A pointer to the first node in the linked list
tail - A pointer to the last node in the linked list
current - A pointer to the node in the list that the new node
is to be added af